package com.menhai.personmanagement.services;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.menhai.personmanagement.entity.MbPopulation;
import com.menhai.personmanagement.entity.SysRole;
import com.menhai.personmanagement.mapper.SysRoleMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务类
 * </p>
 *
 * @author shikun
 * @since 2021-12-07
 */
 @Service
public class ISysRoleService{

    @Autowired
    private SysRoleMapper sysRoleMapper;

    public int addRole(SysRole sysRole){
        return sysRoleMapper.insert(sysRole);
    }

    public Page<SysRole> selectAll(int pagesize,int size){
        Page<SysRole> page = new Page<>(pagesize,size);
        return sysRoleMapper.selectPage(page, null);
    }
    public List<SysRole> selectAll(){
        return sysRoleMapper.selectList(null);
    }

    public int editRole(SysRole sysRole){
        return sysRoleMapper.updateById(sysRole);
    }

    public List findRole(String name){
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("name",name);
        return sysRoleMapper.selectList(queryWrapper);
    }

    public int delRole(int id){
        return sysRoleMapper.deleteById(id);
    }
}
